*************************************************************************
****************** Figure 6: Wages of Different Groups ******************
*************************************************************************
grstyle init
grstyle set plain


cd $PATH

use indinc_analysis.dta, clear
egen group=group(commid WAVE)

preserve
keep commid WAVE group
duplicates drop
save commid.dta, replace
restore


keep if age>=16 & age<=50 /* working population -- retirement age for blue-collar workers: 50 for female*/

collapse (mean) wage_cpi, by(group occupation)
keep if occupation==1|occupation==2|occupation==4|occupation==5

reshape wide wage_cpi, i(group) j(occupation)
merge 1:1 group using commid.dta, keep(match) nogen

merge m:1 commid using kernelmatch.dta, keep(match) nogen
merge 1:1 commid WAVE using so2_match_long.dta, keep(match) nogen 
merge 1:1 commid WAVE using urban_index.dta, keep(match) nogen


local var wage_cpi1 wage_cpi2 wage_cpi4 wage_cpi5
foreach x of local var{
	g log`x'=log(`x')
}

g post=WAVE>1998

eststo clear
global score comm denc div econ health house market soc trans edc mart sani

xtset commid WAVE

eststo: xtreg logwage_cpi1  tcz##post $score i.WAVE, fe vce(cluster commid)  
eststo: xtreg logwage_cpi2  tcz##post $score i.WAVE, fe vce(cluster commid)  
eststo: xtreg logwage_cpi4  tcz##post $score i.WAVE, fe vce(cluster commid)  
eststo: xtreg logwage_cpi5  tcz##post $score i.WAVE, fe vce(cluster commid)  

esttab, keep(1.tcz#1.post) b(a2) se(a2) ar2 starlevels(* 0.10 ** 0.05 *** 0.01)


* The graph is generated by coefplot (Jann, 2014)
* Jann, B. (2014). Plotting Regression Coefficients and other Estimates. The Stata Journal, 14(4), 708–737. 
* https://doi.org/10.1177/1536867X1401400402

coefplot (est1 est2 est3 est4), drop(_cons) level(90) keep(1.tcz#1.post) aseq swapnames  ciopts(recast(rcap)) yline(0) ytitle(Changes in average wages, size(small))  ///
    groups(est1 = "Administrator/Manager" est2 = "/Office staff" est3="worker" est4="worker" ) vertical   ///
    coeflabels(*1* = "Senior professional" *2* = "Junior professional" *3* = "Skilled" *4* = "Non-skilled") format(%9.2g) mlabel mlabposition(2) mlabgap(*2) 
	
graph export fig6_wage_occu.eps, replace
	
